import MyMusic from './components/MyMusic'
import FindMusic from './components/FindMusic'
import MyFollow from './components/MyFollow'
// HashRouter 包裹整个应用
// Route 路由出口组件
// Link 路由的入口组件
// !#1
import { HashRouter, Route, Link } from 'react-router-dom'

// 路由：Hash 地址和组件之间的对应关系
export default function App() {
  // !#2 HashRouter 包裹整个应用
  return (
    <HashRouter>
      <nav className='navbar navbar-expand-lg navbar-light bg-light'>
        <div className='container'>
          <a className='navbar-brand' href='##'>
            网易云
          </a>
          <button
            className='navbar-toggler'
            type='button'
            data-bs-toggle='collapse'
            data-bs-target='#navbarSupportedContent'
            aria-controls='navbarSupportedContent'
            aria-expanded='false'
            aria-label='Toggle navigation'
          >
            <span className='navbar-toggler-icon'></span>
          </button>
          <div className='collapse navbar-collapse' id='navbarSupportedContent'>
            <ul className='navbar-nav me-auto mb-2 mb-lg-0'>
              {/* //!#3 指定入口 */}
              <li className='nav-item'>
                <Link className='nav-link' to='/findmusic'>
                  发现音乐
                </Link>
              </li>
              <li className='nav-item'>
                <Link className='nav-link' to='/mymusic'>
                  我的音乐
                </Link>
              </li>
              <li className='nav-item'>
                <Link className='nav-link' to='/myfollow'>
                  关注
                </Link>
              </li>
            </ul>
          </div>
        </div>
      </nav>
      <div className='container mt-3'>
        <div className='card'>
          <div className='card-body'>
            {/* //!#4 指定出口 */}
            {/* 当和 path 路径匹配的时候，就展示 FindMusic 组件 */}
            <Route path='/findmusic' component={FindMusic} />
            <Route path='/mymusic' component={MyMusic} />
            <Route path='/myfollow' component={MyFollow} />
          </div>
        </div>
      </div>
    </HashRouter>
  )
}
